Skip to content

[kafka] Implement Metadata API over Fluss table metadata - #4261

Draft
gyang94 wants to merge 7 commits into
apache:mainfrom
gyang94:codex/kafka-metadata-api
Draft

gyang94 wants to merge 7 commits into
apache:mainfrom
gyang94:codex/kafka-metadata-api

Conversation

@gyang94

@gyang94 gyang94 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Purpose

Closes #4266. Part of #4185.

Expose pre-created Fluss tables through Kafka Metadata using the shared database.table DDL mapping contract. Queries discover compatible tables across databases and preserve brokers and valid topics when another requested table or database is missing.

This is PR04, depending on PR03 DDL table mapping (#4277 / #4275), which builds on PR02 ApiVersions (#4260 / #4265) and PR01 (#4259 / #4264).

Brief change log

  • Implement Metadata v0-v11 with a narrow backend contract and a TabletServer gateway adapter, and register it in ApiVersions.
  • Resolve qualified topic names to complete Fluss table paths. Enumerate databases for all-topic discovery and return qualified names, keeping same-named tables in different databases distinct.
  • Reuse PR03's topic identity mapper and schema resolver, reading descriptors from the existing table_json field. Reject bare or malformed topic names.
  • Omit incompatible mappings from all-topic discovery; return INVALID_TOPIC_EXCEPTION for incompatible named topics and UNKNOWN_TOPIC_OR_PARTITION for missing tables or databases.
  • Treat synchronous and asynchronous DatabaseNotExistException during table listing as an empty database, including deletion after database enumeration. Preserve other gateway failures.
  • Map brokers, partitions, leaders, replica assignments, authoritative ISR, and offline replicas while preserving the Kafka listener context. Retain the available-leader ISR fallback for legacy metadata; honor authoritative ISR whenever a bucket epoch is present, including an empty ISR or epoch -1.
  • Handle table-deletion races and unavailable leaders. Reject ID-only lookup in v10/v11.

Increment relative to PR03: 10 files changed, 1896 insertions(+), 4 deletions(-). The shared DDL mapping implementation belongs to #4277; this increment keeps the Metadata protocol, gateway adapter and regression coverage together.

Tests

Validated the source tree committed as 988918e255c502c9b8030b00e68d0d0eed0e21c7 on Java 11:

  • mvn -o -pl fluss-kafka -am verify '-Dtest=Kafka*Test,Kafka*ITCase' -Dsurefire.failIfNoSpecifiedTests=false: 90 unit tests and 4 integration tests passed using dependencies from the same reactor.
  • Metadata coverage includes v0-v11, cross-database names, stable topic IDs, invalid/incompatible/missing topics, database deletion, synchronous and asynchronous gateway failures, listener propagation, and legacy/authoritative ISR behavior.
  • Real Kafka listener tests verify cross-database queries and database deletion with single-topic, mixed-topic and all-topic requests for every supported version.
  • Checkstyle, Spotless, RAT and git diff --check passed.
  • Five additional temporary review probes passed with two interleaved requests and completions on another thread, checking listener/client-address isolation, missing-database recovery, unexpected failures and broker-only responses.

The full repository test suite and a Flink SQL runtime were not run.

API and Format

Adds Kafka Metadata v0-v11 for tables satisfying the current DDL mapping contract. Existing Fluss RPC and storage formats are reused. Kafka CreateTopics/DeleteTopics, automatic table creation, Metadata v12+, Produce, and JSON record conversion remain outside this PR.

Documentation

The supported versions, qualified topic names, DDL admission rules and per-topic errors are described in this PR, source Javadoc and regression tests. Produce delivery documentation follows with later capability work.

Stack and review

  1. [kafka] Add request dispatch and transport framework #4259 — PR01: request and transport framework.
  2. [kafka] Serve ApiVersions from registered capabilities #4260 — PR02: ApiVersions.
  3. [kafka] Define DDL table mapping for Kafka compatibility #4277 — PR03: DDL table mapping contract.
  4. This PR — PR04: Metadata.

This PR remains a draft until its prerequisites land. It targets Apache main, so GitHub's Files changed view includes the prerequisites. Metadata is rebased onto PR03 4361fa11b227f6d5573757b21499f692a289cc12; review it using the incremental comparison against DDL mapping. Update the baseline after prerequisites merge and validate again before marking ready.

Generative AI disclosure: Codex assisted with implementation, testing, and commit organization. Human review is required before merge.

gyang94 and others added 7 commits September 16, 2026 16:41
Introduce API registration, request context, version validation, and
asynchronous error mapping. Fix request buffer ownership and response
serialization cleanup while preserving the existing ApiVersions entry point.

Validated with mvn -o -pl fluss-rpc,fluss-kafka verify.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 555/555
AI-Contributed/UT: 525/525
Catch failures while mapping asynchronous handler results so the dispatcher
future completes exceptionally instead of remaining pending. Cover handler
futures that fail before and after dispatch registers its callback.

Validated with Java 11: Maven reactor build and 17 targeted Kafka tests,
including Checkstyle, Spotless, and license checks.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 27/27
AI-Contributed/UT: 28/28
Route requests through the dispatcher and advertise only implemented APIs.
Return version-aware errors for unsupported APIs and invalid requests.

Validated with mvn -o -pl fluss-kafka verify (23 unit tests and 1 IT).

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 313/313
AI-Contributed/UT: 137/137
Extract topic identity and the raw/string table mapping contract before Metadata. Validate table kinds, field projections and metadata columns independently of request handling and record decoding.

Validation: Java 11, mvn -o -pl fluss-kafka clean verify (47 unit tests and 2 integration tests); Checkstyle, Spotless and RAT passed.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 769/769
AI-Contributed/UT: 480/480
Resolve database.table topic names directly to Fluss table paths and return
qualified names for metadata. Validate name boundaries and cover same-named
tables in different databases through native metadata round trips.

Read projected field names directly from DataField to avoid rebuilding the
complete field-name list for every projected column.

Validated on Java 11: 67 Kafka unit tests and 2 integration tests passed,
along with Checkstyle, Spotless, RAT, and git diff --check.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 52/52
AI-Contributed/UT: 167/167
Integrate the DDL mapping prerequisite and use its resolver for Metadata discovery. Omit unsupported tables from all-topic queries and return per-topic mapping errors for named queries. Preserve metadata for compatible tables in mixed requests.

Validation: Java 11, mvn -o -pl fluss-kafka clean verify (62 unit tests and 2 integration tests); Checkstyle, Spotless and RAT passed.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 742/742
AI-Contributed/UT: 571/571
Route Metadata queries through the database.table mapping from PR03 and
enumerate compatible topics across databases. Preserve brokers and valid
topics when a requested database is absent or disappears during discovery;
propagate other gateway failures.

Cover qualified names, same-named tables across databases, synchronous and
asynchronous lookup failures, and Metadata v0-v11 over a real listener.

Validated on Java 11: 90 unit tests and 4 integration tests passed, along
with Checkstyle, Spotless, RAT, and git diff --check. Five additional
interleaved asynchronous review probes passed.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 129/129
AI-Contributed/UT: 514/514
@gyang94
gyang94 force-pushed the codex/kafka-metadata-api branch from 050b260 to 988918e Compare September 17, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kafka] Implement Metadata API for pre-created Fluss tables

1 participant